upgrade to zig 0.16.0#30
Conversation
4c00d1c to
8d0c41d
Compare
There was a problem hiding this comment.
Pull request overview
Updates the project to be compatible with Zig 0.16.0 by adapting timing/IO APIs, allocator-aware deinit calls, vector indexing rules, and NaN semantics changes in min/max.
Changes:
- Bump minimum Zig version to 0.16.0.
- Refactor benchmarks to use
std.process.Init+std.Io.Clockand allocator-awareArrayList.deinit. - Update
min/maxNaN behavior and fix vector runtime indexing in FFT tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/root.zig | Adjusts min/max NaN semantics and fixes runtime vector element access in FFT tests. |
| src/benchmark.zig | Migrates benchmarks to Zig 0.16 “juicy main” init + std.Io.Clock, and updates ArrayList.deinit signatures. |
| build.zig.zon | Raises .minimum_zig_version to 0.16.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const Child = std.meta.Child(T); | ||
| // v != v is true only when v is NaN | ||
| const nan0 = v0 != v0; | ||
| const nan1 = v1 != v1; | ||
| // if v0 is NaN, pick v1 | ||
| // else if v1 is NaN, pick v0 | ||
| // else pick normal @min | ||
| return @select(Child, nan0, v1, @select(Child, nan1, v0, @min(v0, v1))); |
There was a problem hiding this comment.
std.meta.Child(T) will fail to compile when T is a scalar type (e.g. f32, i32), even though this function’s anytype signature previously allowed scalar @min usage. Consider deriving the element type only for vectors (e.g. via @typeInfo(T)), and otherwise using T itself as the @select type parameter so scalar callers still compile.
| const Child = std.meta.Child(T); | |
| // v != v is true only when v is NaN | |
| const nan0 = v0 != v0; | |
| const nan1 = v1 != v1; | |
| // if v0 is NaN, pick v1 | |
| // else if v1 is NaN, pick v0 | |
| // else pick normal @min | |
| return @select(Child, nan0, v1, @select(Child, nan1, v0, @min(v0, v1))); | |
| const SelectT = switch (@typeInfo(T)) { | |
| .Vector => |info| info.child, | |
| else => T, | |
| }; | |
| // v != v is true only when v is NaN | |
| const nan0 = v0 != v0; | |
| const nan1 = v1 != v1; | |
| // if v0 is NaN, pick v1 | |
| // else if v1 is NaN, pick v0 | |
| // else pick normal @min | |
| return @select(SelectT, nan0, v1, @select(SelectT, nan1, v0, @min(v0, v1))); |
There was a problem hiding this comment.
I don't think supporting scalar types here is actually important.
| const T = @TypeOf(v0, v1); | ||
| const Child = std.meta.Child(T); | ||
| // v != v is true only when v is NaN |
There was a problem hiding this comment.
Same issue as min: using std.meta.Child(T) will not compile for scalar T, turning max into a vector-only API despite its generic signature. Use a conditional element-type derivation for vectors and fall back to T for scalar types when calling @select.
@select, since@min/@maxNaN propagation behavior changed